document.addEventListener('DOMContentLoaded', function() {
    // 语言切换功能
    const langZhBtn = document.getElementById('lang-zh');
    const langEnBtn = document.getElementById('lang-en');
    
    // 中文翻译
    const chineseText = {
        'main-title': '联系我们',
        'customer-service-title': '客户服务',
        'customer-service-desc': '我们的客服团队随时为您提供帮助',
        'phone-title': '电话支持',
        'phone-desc': '周一至周日 9:00-18:00',
        'wechat-title': '微信客服',
        'wechat-desc': '扫描二维码添加客服微信',
        'email-title': '电子邮件',
        'email-desc': '24小时内回复',
        'cooperation-title': '合作投稿中心',
        'cooperation-desc': '欢迎加入我们的平台，共创美好未来',
        'local-guide-title': '招募本地导游',
        'local-guide-desc': '如果您熟悉当地文化景点，欢迎加入我们的导游团队',
        'merchant-title': '商家入驻',
        'merchant-desc': '为您的商家提供更多曝光机会和客户资源',
        'contribution-title': '内容投稿',
        'contribution-desc': '分享您的旅行故事或当地资讯',
        'apply-guide-btn': '立即申请',
        'apply-merchant-btn': '申请入驻',
        'contribute-btn': '我要投稿',
        'faq-title': '常见问题',
        'faq1-q': '如何成为认证导游？',
        'faq1-a': '请点击上方"立即申请"按钮填写申请表，我们会在3个工作日内审核您的资料并与您联系。',
        'faq2-q': '商家入驻需要什么条件？',
        'faq2-a': '商家需提供营业执照和相关资质证明，通过审核后即可入驻平台。',
        'copyright': '© 2023 旅行服务平台. 保留所有权利.'
    };
    
    // 英文翻译
    const englishText = {
        'main-title': 'Contact Us',
        'customer-service-title': 'Customer Service',
        'customer-service-desc': 'Our customer service team is ready to help you',
        'phone-title': 'Phone Support',
        'phone-desc': 'Monday to Sunday 9:00-18:00',
        'wechat-title': 'WeChat Service',
        'wechat-desc': 'Scan QR code to add our WeChat',
        'email-title': 'Email',
        'email-desc': 'Response within 24 hours',
        'cooperation-title': 'Cooperation Center',
        'cooperation-desc': 'Join our platform for a better future',
        'local-guide-title': 'Local Guide Recruitment',
        'local-guide-desc': 'If you know local culture and attractions, join our guide team',
        'merchant-title': 'Merchant Application',
        'merchant-desc': 'Get more exposure and customers for your business',
        'contribution-title': 'Content Contribution',
        'contribution-desc': 'Share your travel stories or local information',
        'apply-guide-btn': 'Apply Now',
        'apply-merchant-btn': 'Apply for Merchant',
        'contribute-btn': 'Submit Content',
        'faq-title': 'FAQ',
        'faq1-q': 'How to become a certified guide?',
        'faq1-a': 'Please click the "Apply Now" button above to fill out the application form. We will review your information within 3 working days and contact you.',
        'faq2-q': 'What are the requirements for merchant application?',
        'faq2-a': 'Merchants need to provide business license and relevant certificates. After approval, you can join our platform.',
        'copyright': '© 2023 Travel Service Platform. All rights reserved.'
    };
    
    // 切换语言函数
    function switchLanguage(lang) {
        const textMap = lang === 'zh' ? chineseText : englishText;
        
        for (const [id, text] of Object.entries(textMap)) {
            const element = document.getElementById(id);
            if (element) {
                if (element.tagName === 'INPUT' || element.tagName === 'BUTTON') {
                    element.value = text;
                } else {
                    element.textContent = text;
                }
            }
        }
        
        // 更新语言按钮状态
        if (lang === 'zh') {
            langZhBtn.classList.add('active');
            langEnBtn.classList.remove('active');
        } else {
            langEnBtn.classList.add('active');
            langZhBtn.classList.remove('active');
        }
    }
    
    // 事件监听
    langZhBtn.addEventListener('click', () => switchLanguage('zh'));
    langEnBtn.addEventListener('click', () => switchLanguage('en'));
    
    // 默认显示中文
    switchLanguage('zh');
    
    // FAQ 折叠功能
    const faqQuestions = document.querySelectorAll('.faq-question');
    
    faqQuestions.forEach(question => {
        question.addEventListener('click', () => {
            const faqItem = question.parentElement;
            faqItem.classList.toggle('active');
            
            // 切换图标
            const icon = question.querySelector('i');
            if (faqItem.classList.contains('active')) {
                icon.classList.remove('fa-chevron-down');
                icon.classList.add('fa-chevron-up');
            } else {
                icon.classList.remove('fa-chevron-up');
                icon.classList.add('fa-chevron-down');
            }
        });
    });
    
    // 按钮点击事件
    const applyButtons = document.querySelectorAll('.btn');
    
    applyButtons.forEach(button => {
        button.addEventListener('click', function() {
            const currentLang = langZhBtn.classList.contains('active') ? 'zh' : 'en';
            const message = currentLang === 'zh' 
                ? '感谢您的申请，我们将尽快与您联系！' 
                : 'Thank you for your application, we will contact you soon!';
            
            alert(message);
        });
    });
});